function test_01() {
	// alert("hello world");
	var name = "hanzhengyan";
	var age = 21;
	console.log(`${name} 今年 ${age} 岁`);

	// 字符串方法
	var test = "Welcome Chongqing.";
	console.log(test.length);
	console.log(test.toUpperCase());
	console.log(test.toLowerCase());
	console.log(test.indexOf("o"));
	console.log(test.substring(1, 10));

	//数组
	var arr = ["han", 21, true, null];
	console.log(arr);
	console.log(arr.length);
	console.log(arr[1]);
	arr.push("aaa");
	console.log(arr);
	arr.sort();
	console.log(arr);
	console.log(arr.join("-"));
	var a1 = [1, 2, 3, 4, 5]; //定义数组
	var b1 = a1.slice(2, 5); //截取第二个到第四个
	console.log(b1); //返回[3,4,5]

	//对象
	var student = {
		id: 1,
		name: "han",
		age: 21,
		gender: "male",
	};
	console.log(student);
	console.log(student.name);
	// 判断是否存在name属性
	console.log(student.hasOwnProperty("name"));
	delete student.gender;
	console.log(student);

	//map
	var map = new Map();
	map.set("name", "han");
	map.set("age", 21);
	console.log(map);
	console.log(map.has("name"));
	console.log(map.get("name"));
	map.delete("age");
	console.log(map);

	//set
	var set = new Set();
	set.add("name");
	set.add("han");
	set.add("han");
	console.log(set);
	set.delete("han");
	console.log(set);

	//运算符
	console.log(5 % 3);
	console.log(-5 % 3);
	console.log(5 % -3);
	console.log(-5 % -3);

	console.log(1 == "1");
	console.log([1, 2, 3] == [1, 2, 3]);
	console.log([] == []);
	console.log(null == undefined);
	console.log(null === undefined);
	console.log(NaN == NaN);

	//判断
	var age = 21;
	if (age <= 18) {
		console.log("青少年");
	} else if (age > 18 && age < 65) {
		console.log("中壮年");
	} else {
		console.log("老年");
	}

	// 循环
	var i;
	for (i = 0; i < arr.length; i++) {
		console.log(arr[i]);
	}
	arr.forEach(function (item) {
		console.log(item);
	});
	// set循环
	var s = new Set(["A", "B", "C"]);
	s.forEach(function (element) {
		console.log(element);
	});
	// map循环
	var m = new Map([
		[1, "x"],
		[2, "y"],
		[3, "z"],
	]);
	m.forEach(function (value, key) {
		console.log(value);
	});

	// 箭头函数
	var arr2 = [1, 3, 5, 4, 2, 9, 6];
	// 循环
	arr2.forEach((item) => console.log(item));
	// 包装
	console.log(arr2.map((item) => item * 3));
	// 累加
	var sum = 0;
	arr2.forEach(function (item) {
		sum += item;
	});
	console.log(sum);
	console.log(arr2.reduce((item1, item2) => item1 + item2));
	// 过滤
	console.log(arr2.filter((item) => item % 2 == 0));
	// 排序
	console.log(arr2.sort((a, b) => a - b));

	// 日期
	var date = new Date();
	console.log(date.getFullYear() + "-" + (date.getMonth() + 1) + "-" + date.getDay());
	console.log(Date.parse("2022-06-15 15:21:22"));
	// 时间戳转日期
	var d = new Date(1655277682000);
	console.log(d);

	// 正则表达式
	var newLingReg = /^我是一个(\d+)岁的男生$/;
	var news = "我是一个21岁的男生";
	console.log(newLingReg.exec(news));

	//JOSN
	console.log(student);
	console.log(JSON.stringify(student));

	//Math
	console.log(Math.floor(Math.random() * 100 + 1));
}
